/*
COVID PROJECT
NAME OF PERSON EDITING: GIRIJA BAHETY
Date: April 2021
Stata 16.1 Windows
*/

/*
NOTES TO DATA ANALYSIS:
	1. Treatment effect regressions (each regression should control for strata variables)
		- by pooled treatment
		- by 5 frames
		- by 2 timings
		- by 10 arms
*/

clear all
set more off
capture log close

********************************************************************************

log using "$logfiles/analysis_key_itt_`c(current_date)'_controlstest.log", replace

use "$covidclean/smscovid_clean.dta", clear

***Keep relevant observations: consent taken and above 18 years of age, non-missing treatment arms
	keep if consent==1 & age>=18
	keep if ~missing(treatment_arm)
	count //3964

***HOUSEKEEPING - BEHAVIOR TREATMENTS, OUTCOMES, ROW TITLES

	***Create dummies with treatment arms interacted with behavior
		foreach v in $treat_pool $treat_frames $treat_timings $treat_arms {
			gen `v'_sd = `v'*behavior_sd
			gen `v'_hw = `v'*behavior_hw
		}
		
	***Outcomes
		global keysdhw know_sd act_sd know_hw act_hw

********************************************************************************
***MAIN ITT REGRESSIONS
********************************************************************************
	
		qui foreach v of varlist $keysdhw {
			
				*W/o any controls
				noi di "Outcome = `v' - without any controls"
				noi reg `v' $treat_pool_sd $treat_pool_hw if $sample, vce(robust)
				
				*With strata fixed effects
				noi di "Outcome = `v' - with strata fixed effects only - stratum roundofinterview behavior"
				noi reghdfe `v' $treat_pool_sd $treat_pool_hw if $sample, a(stratum roundofinterview behavior_sd) vce(robust)
				
				*With study fixed effects
				noi di "Outcome = `v' - with study fixed effects"
				noi reghdfe `v' $treat_pool_sd $treat_pool_hw if $sample, a($studycontrols) vce(robust)
		}
		
exit, clear		